home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / dev / misc / gms_dev.lha / GMS / Source / Asm / Chunky / ChunkyBuffered.s < prev    next >
Encoding:
Text File  |  1997-07-08  |  4.4 KB  |  196 lines

  1. ;-------T-------T------------------------T----------------------------------;
  2. ;Name:      Chunky Pixel List (Buffered)
  3. ;Author:    Paul Manias
  4. ;Copyright: DreamWorld Productions (c) 1996-1997.  Freely distributable.
  5. ;
  6. ;This demo is like the other pixel list demos but uses a CHUNKY8 screen type.
  7. ;Then screen size has been kept very small as the C2P routine is too slow,
  8. ;but this will be improved in the next version.  The good thing is that
  9. ;because the routine is transparent, using a graphics card would mean that
  10. ;this demo would run at the maximum possible speed.
  11. ;
  12. ;Press LMB to exit.
  13.  
  14.     INCDIR    "INCLUDES:"
  15.     INCLUDE    "games/games_lib.i"
  16.     INCLUDE    "games/games.i"
  17.  
  18.     SECTION    "Demo",CODE
  19.  
  20. ;===========================================================================;
  21. ;                             INITIALISE DEMO
  22. ;===========================================================================;
  23.  
  24.     STARTGMS
  25.  
  26. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  27.     move.l    GMSBase(pc),a6
  28.     CALL    AllocBlitter
  29.     tst.l    d0
  30.     bne.s    .Error_Blitter
  31.  
  32.     lea    ScreenTags(pc),a0
  33.     CALL    ShowScreen
  34.     tst.l    d0
  35.     beq.s    .Error_Screen
  36.  
  37.     CALL    InitJoyPorts
  38.  
  39.     bsr.s    Main
  40.  
  41. .ReturnToDOS
  42.     move.l    GMSBase(pc),a6
  43.     move.l    Screen(pc),a0
  44.     CALL    DeleteScreen
  45. .Error_Screen
  46.     CALL    FreeBlitter
  47. .Error_Blitter
  48.     MOVEM.L    (SP)+,A0-A6/D1-D7
  49.     moveq    #ERR_OK,d0
  50.     rts
  51.  
  52. ;===========================================================================;
  53. ;                                MAIN LOOP
  54. ;===========================================================================;
  55.  
  56. Main:
  57. .loop    move.l    Screen(pc),a1
  58.     move.l    GS_Bitmap(a1),a0
  59.     move.l    GS_MemPtr2(a1),BMP_Data(a0)
  60.     CALL    ClearBitmap
  61.  
  62.     lea    MList(pc),a2    ;a2 = Pointer to pixel list.
  63.     move.l    a2,a3    ;Drop the pixels here.
  64.     moveq    #31-1,d7
  65. .drop    addq.w    #1,2(a3)    ;a3 = YCoord+1
  66.     subq.l    #1,4(a3)    ;a3 = (Colour)-1
  67.     bge.s    .colok
  68.     clr.l    4(a3)
  69. .colok    addq.w    #8,a3
  70.     dbra    d7,.drop
  71.  
  72.     lea    MouseX(pc),a5
  73.     moveq    #JPORT1,d0
  74.     moveq    #JT_ZBXY,d1
  75.     CALL    ReadJoyPort
  76.     btst    #MB_LMB,d0
  77.     bne.s    .done
  78.     move.w    d0,d1
  79.     ext.w    d1    ;d1 = Extend the Y byte.
  80.     asr.w    #8,d0    ;d0 = Extend the X byte.
  81.  
  82.     move.l    Screen(pc),a0    ;a0 = Screen.
  83.     add.w    (a5),d0    ;d0 = (MouseX)+ChangeX
  84.     add.w    2(a5),d1    ;d1 = (MouseY)+ChangeY
  85.  
  86. .ChkRX    cmp.w    GS_ScrWidth(a0),d0
  87.     blt.s    .ChkLX
  88.     moveq    #$00,d0
  89.     bra.s    .Calculate
  90.  
  91. .ChkLX    tst.w    d0
  92.     bgt.s    .ChkTY
  93.     move.w    GS_ScrWidth(a0),d0
  94.     bra.s    .Calculate
  95.  
  96. .ChkTY    tst.w    d1
  97.     bgt.s    .ChkBY
  98.     move.w    GS_ScrHeight(a0),d1
  99.     bra.s    .Calculate
  100.  
  101. .ChkBY    cmp.w    GS_ScrHeight(a0),d1
  102.     blt.s    .Calculate
  103.     moveq    #$00,d1
  104.  
  105. .Calculate
  106.     move.w    d0,(a5)
  107.     move.w    d1,2(a5)
  108.  
  109.     move.l    (a5),-(sp)
  110.     moveq    #2,d1
  111.     CALL    FastRandom
  112.     subq.w    #1,d0
  113.     add.w    d0,(a5)
  114.  
  115.     moveq    #2,d1
  116.     CALL    FastRandom
  117.     subq.w    #1,d0
  118.     add.w    d0,2(a5)
  119.  
  120.     move.l    a2,a3
  121.     moveq    #31-1,d7
  122. .tloop    move.l    8(a3),(a3)
  123.     move.l    12(a3),4(a3)
  124.     addq.w    #8,a3
  125.     dbra    d7,.tloop
  126.  
  127.     move.l    Screen(pc),a0
  128.     move.l    GS_Bitmap(a0),a0
  129.     lea    PixelList(pc),a1    ;a1 = Pixel list.
  130.     CALL    DrawPixelList    ;>> = Draw pixels with clipping.
  131.     move.l    (sp)+,(a5)
  132.  
  133.     CALL    WaitVBL
  134.  
  135.     move.l    Screen(pc),a0
  136.     CALL    SwapBuffers
  137.     bra    .loop
  138. .done    rts
  139.  
  140. ;===========================================================================;
  141. ;                                  DATA
  142. ;===========================================================================;
  143.  
  144. ScreenTags:
  145.     dc.l    TAGS_GAMESCREEN
  146. Screen:    dc.l    0
  147.     dc.l    GSA_ScrWidth,128
  148.     dc.l    GSA_ScrHeight,128
  149.     dc.l    GSA_Palette,.palette
  150.     dc.l    GSA_AmtColours,32
  151.     dc.l    GSA_Attrib,DBLBUFFER|CENTRE
  152.     dc.l    GSA_ScrType,CHUNKY8
  153.     dc.l    TAGEND
  154. .palette
  155.     dc.l $000000,$101010,$171717,$202020,$272727,$303030,$373737,$404040
  156.     dc.l $474747,$505050,$575757,$606060,$676767,$707070,$777777,$808080
  157.     dc.l $878787,$909090,$979797,$a0a0a0,$a7a7a7,$b0b0b0,$b7b7b7,$c0c0c0
  158.     dc.l $c7c7c7,$d0d0d0,$d7d7d7,$e0e0e0,$e0e0e0,$f0f0f0,$f7f7f7,$ffffff
  159.  
  160. PixelList:
  161.     dc.w    32,PXL_SIZEOF    ;Amount of entries, EntrySize.
  162.     dc.l    MList    ;Pointer to pixel list array.
  163. MList    PIXEL    16,12,00    ;First pixel to draw (at back)
  164.     PIXEL    16,12,00    ;X/Y/Colour
  165.     PIXEL    16,12,00    ;..
  166.     PIXEL    16,12,00    ;..
  167.     PIXEL    16,12,00    ;..
  168.     PIXEL    16,12,00    ;..
  169.     PIXEL    16,12,00    ;..
  170.     PIXEL    16,12,00    ;..
  171.     PIXEL    16,12,00    ;..
  172.     PIXEL    16,12,00    ;..
  173.     PIXEL    16,12,00    ;..
  174.     PIXEL    16,12,00    ;..
  175.     PIXEL    16,12,00    ;..
  176.     PIXEL    16,12,00    ;..
  177.     PIXEL    16,12,00    ;..
  178.     PIXEL    16,12,00    ;..
  179.     PIXEL    16,12,00    ;..
  180.     PIXEL    16,12,00    ;..
  181.     PIXEL    16,12,00    ;..
  182.     PIXEL    16,12,00    ;..
  183.     PIXEL    16,12,00    ;..
  184.     PIXEL    16,12,00    ;..
  185.     PIXEL    16,12,00    ;..
  186.     PIXEL    16,12,00    ;..
  187.     PIXEL    16,12,00    ;..
  188.     PIXEL    16,12,00    ;..
  189.     PIXEL    16,12,00    ;..
  190.     PIXEL    16,12,00    ;..
  191.     PIXEL    16,12,00    ;..
  192.     PIXEL    16,12,00    ;..
  193.     PIXEL    16,12,00    ;..
  194. MouseX    PIXEL    16,12,31    ;Last pixel to draw (in front)
  195.  
  196.